<script setup lang="ts">
import { ref } from "vue";
import router from "@/router";
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
import { useRoute } from "vue-router";
import { getDictList } from "@/api/dict";

const multiTagsStore = useMultiTagsStoreHook();
const route = useRoute();

let form = ref({
  inboundType: "",
  materialName: "",
  materialSpecs: "",
  warehouseName: "",
  inboundCode: "",
  relateOrderCode: "",
  createName: "",
  createTime: "",
  memo: ""
});
const inboundTypeList = ref([]);

const getInboundTypeList = async () => {
  const res = await getDictList({ dictCode: "INBOUND_TYPE_M" });
  inboundTypeList.value = res.data || [];
};
getInboundTypeList();

const goBack = () => {
  multiTagsStore.handleTags("splice", route.path);
  router.back();
};


defineExpose({
  getForm: () => form.value,
  setForm: (data: any) => {
    form.value = data;
  }
});
</script>

<template>
  <div class="applyForm">
    <div class="flex items-center justify-between flex-row pb-[16px]">
      <p class="text-[16px] font-bold">入库管理信息</p>
      <el-button @click="goBack"
        ><svg-icon name="rollback" size="16" /> 返回</el-button
      >
    </div>
    <el-descriptions class="pr-[80px] mb-[-12px]">
      <el-descriptions-item label="入库类型：">
        {{
          inboundTypeList.find(item => item.dictLabelValue == form.inboundType)
            ?.dictLabelName
        }}
      </el-descriptions-item>
      <el-descriptions-item label="入库仓库名称：">
        {{ form.warehouseName }}
      </el-descriptions-item>
      <el-descriptions-item label="入库单编号：">
        {{ form.inboundCode }}
      </el-descriptions-item>
      <el-descriptions-item label="关联单据号：">
        {{ form.relateOrderCode }}
      </el-descriptions-item>
      <el-descriptions-item label="操作人：">
        {{ form.createName }}
      </el-descriptions-item>
      <el-descriptions-item label="入库时间：">
        {{ form.createTime }}
      </el-descriptions-item>
      <el-descriptions-item label="备注：">
        {{ form.memo }}
      </el-descriptions-item>
    </el-descriptions>
  </div>
</template>

<style scoped lang="scss">
.applyForm {
  overflow: hidden;
}
</style>
